#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
  char str[100];
  gets(str);
  int len=0, i, sum=0;
  if(str[0]=='#'&&str[1]=='\0')
  {
    printf("0");
    return 0;
  }
  len = strlen(str);
  for(i=1; i<len/2; i++)
  {
  	if(str[i]!='#'&&str[2*i]=='#'&&str[2*i+1]=='#')
  	{
  		sum += (str[i]-'0')*(int)(log2(i));
	}
  }
  for( ; i<len; i++)
      if(str[i]!='#')
	      sum += (str[i]-'0')*(int)(log2(i));
  printf("%d", sum);
 
  return 0;
}
